﻿using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.SimulateTrigger, typeof(LevelServiceGraph))]
    public class LevelServiceExecutionNode_SimulateTrigger : LevelServiceExecutionNode
    {
        protected override ServiceExecutionType mServiceType => ServiceExecutionType.SimulateTrigger;
        public override string name => LevelEditorConst.SimulateTrigger;
        [Output("模拟目标", false)] public EditorLevelServiceTargetSetter tagOrMcid;
        [Output("触发器")] public LevelServiceExecutionCustom_SimulateTrigger triggerConfig;

        protected override LevelServiceCustomConfig CreateConfig()
        {
            this.triggerConfig = new LevelServiceExecutionCustom_SimulateTrigger()
            {
                // tagOrMcid = this.tagOrMcid,
            };
            this.tagOrMcid = new EditorLevelServiceTargetSetter(x => triggerConfig.tagOrMcid = x);
            return this.triggerConfig;
        }
        
        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
            if (newConfig.customConfig is LevelServiceExecutionCustom_SimulateTrigger rConfig)
            {
                this.SyncTarget(rConfig.tagOrMcid);
            }
        }
    }
}